Excel document property is just like the background of a person. When we want to know a person, the basic information is very necessary, such as his name, his hometown, his work and so on. So is the excel document. Excel file property can tell us additional information of this document, such as author, created time, modified time, its size, its title, tags and categories. Actually, you also can set manager, subject, comments, hyperlink base. While how to set excel property with C#, VB.NET? Please look at the below paragraphs.
How to set Excel property with C#, VB.NET?
By using Spire.XLS, I only use three simple steps to finish the Excel property setting task in minutes with C#, VB.NET. Spire.XLS is an independent powerful Excel component. You also can Freely Install Spire.XLS in your system. Please follow the below steps.
Step1. Create a new project.
1. Create a new project in Visual Studio and set the Target Framework to be .NET Framework 2 or above.
2. Add Spire.Xls DLL as reference.
Step2. Set Excel property.
1. Create a new excel workbook and load an excel file from system.
C# Code:
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"D:\michelle\comment.xlsx");
VB.NET Code:
Dim workbook As New Workbook()
workbook.LoadFromFile("D:\michelle\ comment.xlsx")
2. Set Excel property.
C# Code:
workbook.DocumentProperties.Author = "E-iceblue Support Team";
workbook.DocumentProperties.Title = "Properties Demo";
workbook.DocumentProperties.Keywords = "Excel Properties C#, Excel Properties VB.NET";
workbook.DocumentProperties.Category = "Excel Demo";
workbook.DocumentProperties.Company = "E-iceblue";
VB.NET Code: workbook.DocumentProperties.Author = "E-iceblue Support Team"
workbook.DocumentProperties.Title = "Properties Demo"
workbook.DocumentProperties.Keywords = "Excel Properties C#, Excel Properties VB.NET"
workbook.DocumentProperties.Category = "Excel Demo"
workbook.DocumentProperties.Company = "E-iceblue"
Step3. Save and launch the file.
C# Code:
workbook.SaveToFile("Properties.xlsx", ExcelVersion.Version2010);
System.Diagnostics.Process.Start("Properties.xlsx");
VB.NET Code:
workbook.SaveToFile("Properties.xlsx", ExcelVersion.Version2010)
System.Diagnostics.Process.Start("Properties.xlsx")
Preview
As you see, setting Excel property with C#, VB.NET is really as simple as setting it directly in the Excel document. Spire.xls can help you realize the Excel Functions in a quick and simple way with C#, VB.NET.